#include<reg51.h>
sbit R_led=P2^2;
sbit R_led1=P2^3;
sbit R_led2=P2^4;
sbit R_led3=P2^5;
sbit R_led4=P2^6;
sbit R_led5=P2^1;

unsigned char Current,Data[4];
unsigned int temp;

void Send_Char(unsigned char buf);
void Send_Data(void);

void main (void)
{
	SCON = 0x50;
	TMOD = 0x21;
	IE   = 0x87;
	TH0  = 0xEE;
	TL0  = 0x0;
P2=0;
	//  9600????
	TH1  = 0xFD;
	TL1  = 0xFD;
	TCON = 0x55;
   
	while(1)
	{   
		if(Current == 26)
		{
			Current = 0;
			EA = 0;
			Send_Data();
			
			EA = 1;
		
		}
	}
}

void Ex0(void) interrupt 0
{
	Data[(25 - Current) / 8] &= ~(0x1 << ((25 - Current) % 8));
	TH0 = 0xEE;
	TL0 = 0x0;
	Current++;
}

void Ex1(void) interrupt 2
{
	Data[(25 - Current) / 8] |= 0x1 << ((25 - Current) % 8);
	TH0 = 0xEE;
	TL0 = 0x0;
	Current++;
}

void Timer0(void) interrupt 1
{
	TH0 = 0xEE;
	TL0 = 0x0;
	Current = 0;
}

void Send_Char(unsigned char buf)
{
	SBUF = buf;
	while(TI == 0);
	TI = 0;
}

void Send_Data(void)
{
if(Data[1] == 139)
{

R_led = 1;
R_led1 = 1;

R_led2 = 0;
R_led3 = 0;
R_led4 = 0;
R_led5 = 0;
}

if(Data[1] == 196)
{
R_led = 0;
R_led1 = 0;

R_led2 = 1;
R_led3 = 1;

R_led4 = 0;
R_led5 = 0;
}

if(Data[1] == 82)
{

R_led = 0;
R_led1 = 0;

R_led2 = 0;
R_led3 = 0;

R_led4 = 1;
R_led4 = 1;
}

} 
